package edu.hitsz.aircraft.enemy;

import edu.hitsz.application.Main;
import edu.hitsz.bullet.BaseBullet;
import edu.hitsz.bullet.EnemyBullet;
import edu.hitsz.factory.propFactory.*;
import edu.hitsz.prop.AbstractProp;
import edu.hitsz.shootStrategy.ShootRing;
import edu.hitsz.shootStrategy.ShootScatter;
import edu.hitsz.shootStrategy.ShootStrategy;

import java.util.LinkedList;
import java.util.List;

public class BossEnemy extends AbstractEnemy{

    public BossEnemy(int locationX, int locationY, int speedX, int speedY, int hp) {
        super(locationX, locationY, speedX, speedY, hp);
        super.shootNum=20;
        super.power=30;
        super.direction=1;

        super.setShootStrategy(new ShootRing());

    }


    @Override
    public void forward() {
        locationX += speedX;
        if(locationY <= Main.WINDOW_HEIGHT/3) {
            locationY += speedY;
        }
        if (locationX <= 0 || locationX >= Main.WINDOW_WIDTH) {
            // 横向超出边界后反向
            speedX = -speedX;
        }
    }


    @Override
    public List<AbstractProp> dropProp(int LocationX, int LocationY) {

        List<AbstractProp> abstractProps=new LinkedList<>();

        for (int i=0;i<3;i++) {
            double rand = Math.random();
            if(rand<0.8){
                rand=Math.random();
                //抽象道具工厂
                PropFactory propFactory;
                if (rand < 0.25) {
                    //1.创建工厂对象
                    propFactory = new BloodPropFactory();
                } else if (rand < 0.5) {
                    propFactory = new BombPropFactory();
                } else if (rand<0.75){
                    propFactory = new BulletPropFactory();
                } else {
                    propFactory =new BulletPlusPropFactory();
                }

                //2.调用对象的createObject方法
                AbstractProp abstractProp = propFactory.createProp(this.getLocationX() - 50 + i * 50, LocationY);
                abstractProps.add(abstractProp);

            }

        }

        return abstractProps;
    }

    @Override
    public void update() {
        //空实现
    }
}
